home *** CD-ROM | disk | FTP | other *** search
/ The Complete Windows Set / The Complete Windows Set.iso / MICROLIN / DR12DR1.C < prev    next >
C/C++ Source or Header  |  1991-12-29  |  5KB  |  210 lines

  1. #include "io.h"
  2. #include "stdio.h"
  3. #include "fcntl.h"
  4. #include "string.h"
  5. #include "memory.h"
  6. #include "sys\types.h"
  7.  
  8. #define S_IFMT          0170000         /* file type mask */
  9. #define S_IFDIR         0040000         /* directory */
  10. #define S_IFCHR         0020000         /* character special */
  11. #define S_IFREG         0100000         /* regular */
  12. #define S_IREAD         0000400         /* read permission, owner */
  13. #define S_IWRITE        0000200         /* write permission, owner */
  14. #define S_IEXEC         0000100         /* execute/search permission, owner */
  15.  
  16. #define FILENAME           13
  17. #define TITLE              27
  18. #define PORTSTR            15
  19. #define TIMESTR            10
  20. #define PHONE              26
  21. #define INITSTR            26
  22. #define PROFILE            20
  23. #define LISTSTR            20
  24. #define MAXBUFF            128
  25. #define MINBUFF            32
  26. #define RECBUFLEN          4096
  27. #define XMITBUFLEN         4096
  28. #define OLDFILENAME        13
  29. #define OLDTITLE           27
  30. #define OLDPHONE           26
  31. #define OLDLISTSTR         20
  32.  
  33.  
  34. typedef struct tagSESSION
  35. {
  36.     char      szTitle[TITLE];
  37.     char      szPhone[PHONE];
  38.     int       iProtocol;
  39.     char      szScript[FILENAME];
  40.     int       bSessRsvd[10];
  41. } SESSION;
  42.  
  43. typedef struct tagPORT
  44. {
  45.     int       iComPort;
  46.     int       iBaudRate;
  47.     int       iFlowCtl;
  48.     int       iParity;
  49.     int       iDataBits;
  50.     int       iStopBits;
  51.     int       bCarrier;
  52.     int       bLockBaud;
  53.     int       iParityCheck;
  54.     int       bPortRsvd[10];
  55. } PORT;
  56.  
  57. typedef struct tagTERMINAL
  58. {
  59.     int       iTerminal;
  60.     int       iFontSize;
  61.     int       iCaret;
  62.     int       iBufLines;
  63.     int       iRows;
  64.     int       iCols;
  65.     long      crFore;
  66.     long      crBack;
  67.     int       bCRLF;
  68.     int       bAutoWrap;
  69.     int       bEcho;
  70.     int       bColors;
  71.     char      szFont[LISTSTR];
  72.     int       bTermRsvd[10];
  73. } TERMINAL;
  74.  
  75. typedef struct tagZMODEMOPT
  76. {
  77.     int    bAutoDown;
  78.     int    bUseCRC32;
  79.     int    bResume;
  80.     int    iSendMgtOpt;
  81.     int    iRecvMgtOpt;
  82. } ZMODEMOPT;
  83.  
  84. typedef struct tagDIR
  85. {
  86.     SESSION     Session;
  87.     PORT        Port;
  88.     TERMINAL    Terminal;
  89.     ZMODEMOPT   ZModemOpt;
  90. } DIR;
  91.  
  92. typedef struct tagOLDSESSION
  93. {
  94.     char     szTitle[OLDTITLE];
  95.     char     szPhone[OLDPHONE];
  96.     int      iProtocol;
  97.     char     szScript[OLDFILENAME];
  98. } OLDSESSION;
  99.  
  100. typedef struct tagOLDPORT
  101. {
  102.     int      iComPort;
  103.     int      iBaudRate;
  104.     int      iFlowCtl;
  105.     int      iParity;
  106.     int      iDataBits;
  107.     int      iStopBits;
  108. } OLDPORT;
  109.  
  110. typedef struct tagOLDTERMINAL
  111. {
  112.     int      iTerminal;
  113.     int      iFontSize;
  114.     int      iCaret;
  115.     int      iBufLines;
  116.     int      iRows;
  117.     int      iCols;
  118.     long     crFore;
  119.     long     crBack;
  120.     int      bCRLF;
  121.     int      bEcho;
  122.     int      bColors;
  123.     char     szFont[OLDLISTSTR];
  124. } OLDTERMINAL;
  125.  
  126. typedef struct tagOLDDIR
  127. {
  128.     OLDSESSION     OldSession;
  129.     OLDPORT        OldPort;
  130.     OLDTERMINAL    OldTerminal;
  131.     ZMODEMOPT      ZModemOpt;
  132. } OLDDIR;
  133.  
  134.  
  135. main (int argc, char *argv[])
  136. {
  137.    int i;
  138.    DIR Dir;
  139.    int hDest;
  140.    int hSource;
  141.    OLDDIR OldDir;
  142.    char szSource[30];
  143.    char szDest[30];
  144.  
  145.    if (argc < 3)
  146.    {
  147.       printf ("Syntax is DR12DR1 SOURCE DEST\n");
  148.       printf ("where SOURCE is the orginal dir file\n");
  149.       printf ("and DEST is the new dir file\n");
  150.       printf ("example CONVERT MLINK.DIR NEW.DR1\n");
  151.       printf ("You do not need to provide the file extensions\n");
  152.  
  153.       return 1;
  154.    }
  155.    
  156.    strcpy (szSource, argv[1]);
  157.    if (!strchr (argv[1], '.'))
  158.       strcat (szSource, ".dr1");
  159.  
  160.    strcpy (szDest, argv[2]);
  161.    if (!strchr (argv[2], '.'))
  162.       strcat (szDest, ".dr1");
  163.  
  164.    hDest   = creat (szDest, S_IWRITE);
  165.    hSource = open (szSource, O_RDWR | O_BINARY);
  166.  
  167.    memset (&Dir, '\0', sizeof (DIR));
  168.    memset (&OldDir, '\0', sizeof (OLDDIR));
  169.  
  170.    i = sizeof (OLDDIR);
  171.    while (read (hSource, &OldDir, sizeof (OLDDIR)))
  172.    {
  173.     memcpy (&Dir.Session,   &OldDir.OldSession, sizeof (OLDSESSION));
  174.     memcpy (&Dir.ZModemOpt, &OldDir.ZModemOpt,  sizeof (ZMODEMOPT));
  175.  
  176.     Dir.Port.iComPort     = OldDir.OldPort.iComPort;
  177.     Dir.Port.iBaudRate    = OldDir.OldPort.iBaudRate;
  178.     Dir.Port.iFlowCtl     = OldDir.OldPort.iFlowCtl;
  179.     Dir.Port.iParity      = OldDir.OldPort.iParity;
  180.     Dir.Port.iDataBits    = OldDir.OldPort.iDataBits;
  181.     Dir.Port.iStopBits    = OldDir.OldPort.iStopBits;
  182.  
  183.     Dir.Port.bCarrier     = 1;
  184.     Dir.Port.bLockBaud    = 1;
  185.     Dir.Port.iParityCheck = 0;
  186.  
  187.     strcpy (Dir.Terminal.szFont, OldDir.OldTerminal.szFont);
  188.     Dir.Terminal.iTerminal  = OldDir.OldTerminal.iTerminal;
  189.     Dir.Terminal.iBufLines  = OldDir.OldTerminal.iBufLines;
  190.     Dir.Terminal.iRows      = OldDir.OldTerminal.iRows;
  191.     Dir.Terminal.iCols      = OldDir.OldTerminal.iCols;
  192.     Dir.Terminal.bCRLF      = OldDir.OldTerminal.bCRLF;
  193.     Dir.Terminal.bEcho      = OldDir.OldTerminal.bEcho;
  194.     Dir.Terminal.iFontSize  = OldDir.OldTerminal.iFontSize;
  195.     Dir.Terminal.iCaret     = OldDir.OldTerminal.iCaret;
  196.     Dir.Terminal.crFore     = OldDir.OldTerminal.crFore;
  197.     Dir.Terminal.crBack     = OldDir.OldTerminal.crBack;
  198.     Dir.Terminal.bColors    = OldDir.OldTerminal.bColors;
  199.  
  200.     Dir.Terminal.bAutoWrap  = 1;
  201.  
  202.         write (hDest, &Dir, sizeof (DIR));
  203.    } 
  204.    close (hDest);
  205.    close (hSource);
  206. }
  207.  
  208.  
  209.  
  210.